import React, { useState } from 'react';
import { Button, Input, message, Modal } from 'antd';
import axios from 'axios';

export default function Eddata({id}) {
  const [isModalOpen, setIsModalOpen] = useState(false);
  const [bzv,setbzv]=useState("")
  const showModal = () => {
    setIsModalOpen(true);
  };

  const handleOk = () => {
  
    axios.post("http://node.dayuan0307.top:300/victy/bed",{
        id:id,
        bz:bzv
    }).then(res=>{
        console.log(res.data)
        message.info("修改成功")
        setIsModalOpen(false);
    }).catch(err=>{
        console.log(err)
        message.error("修改失败")
        setIsModalOpen(false);
      
    })
   
  };

  const handleCancel = () => {
    setIsModalOpen(false);
  };

  return (
    <>
      <Button type="primary" onClick={showModal}>
    编辑
      </Button>
      <Modal title="修改的分组的内容" open={isModalOpen} onOk={handleOk} onCancel={handleCancel}>
      备注：<Input   value={bzv}   onChange={(e)=>{setbzv(e.target.value)}}  style={{width:"150px", marginLeft:"10px",marginRight:"25px"}} />
      </Modal>
    </>
  );
};


